<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>业务分类管理</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8"/>
    <link rel="stylesheet" href="${re.contextPath}/plugin/layui/css/layui.css">
    <script type="text/javascript" src="${re.contextPath}/plugin/jquery/jquery-3.2.1.min.js"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/layui/layui.all.js" charset="utf-8"></script>
    <script type="text/javascript" src="${re.contextPath}/plugin/tools/tool.js"></script>
</head>

<body>

<form class="layui-form">
    <div class="layui-form-item">
        <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
            <legend style="font-size:16px;">业务分类信息</legend>
        </fieldset>
    </div>

    <div class="layui-form-item">


        <div class="layui-inline">
            <input type="hidden" id="id" name="id" value="${capServiceKind.id}"/>
            <label for="name" class="layui-form-label">
                业务分类名称
            </label>
            <div class="layui-input-inline">
                <input type="text" id="name" name="name" lay-verify="name"
                       autocomplete="off" class="layui-input" value="${capServiceKind.name}">
            </div>
        </div>

        <div class="layui-inline">
            <label for="serviceTypeId" class="layui-form-label">
                业务类型
            </label>
            <div class="layui-input-inline">
                <select name="serviceTypeId" id="serviceTypeId"  class="search_input" style="height:30px;width:120px;" lay-search></select>
            </div>
        </div>

    </div>
<div class="layui-form-item layui-form-text">
    <label class="layui-form-label">备注</label>
    <div class="layui-input-block" style="width:73%">
        <textarea placeholder="请输入备注" class="layui-textarea" name="remarks">${capServiceKind.remarks}</textarea>
    </div>
</div>
    <div style="width: 100%;height: 55px;background-color: white;border-top:1px solid #e6e6e6;
  position: fixed;bottom: 1px;margin-left:-20px;">
        <div class="layui-form-item" style=" float: right;margin-right: 30px;margin-top: 8px">
            <#if (detail!="readonly")>
            <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">
                确定
            </button>
        </#if>
        <button class="layui-btn layui-btn-primary" id="close">
            关闭
        </button>
    </div>
</form>
<script type="text/html" id="serviceTypeTpl">
    <option value=""></option>
    {{#layui.each(d.list,function(index,item){ }}
    <option  value="{{item.id}}" {{item.checked==true?'selected':''}} >{{item.name}}</option>
    {{# }); }}
    {{# if(d.list.length==0){ }}
    无数据
    {{# }}}

</script>
<script>
  var flag,msg;
   layui.use(['laytpl','form'],function(){
    var laytpl = layui.laytpl;
    var form = layui.form;
    loadAllType(laytpl);
    function loadAllType(laytpl){
        $.ajax({
           url:'/type/loadAllServiceType',
           type:'get',
           success:function(res){
                if(res.flag){
                   $("#serviceTypeId").empty();
                   var html="<option></option>";
                   var serviceTypeId = "${capServiceKind.serviceTypeId}";
                   $(res.jsonObj.data).each(function(v,k){
                    if(serviceTypeId==k.id){
                        html+="<option value='"+k.id+"' selected='selected'>"+k.name+"</option>";
                    }else{
                          html+="<option value='"+k.id+"'>"+k.name+"</option>";
                    }
                   });
                   $("#serviceTypeId").append(html);
                    form.render('select');

                }

           },
           beforeSend:function(){
<!--              layer.msg('加载中');-->
           }
        })
  }

  });
  layui.use(['form','layer'], function(){
    $ = layui.jquery;
    var form = layui.form
        ,layer = layui.layer;


    //自定义验证规则
    form.verify({
      name: function(value){
        if(value.trim()==""){
          return "业务类型名称不能为空";
        }
      }
    })

   $('#close').click(function(){
     var index = parent.layer.getFrameIndex(window.name);
     parent.layer.close(index);
     return false;
   });
    //监听提交
    form.on('submit(add)', function(data){

      layerAjax('addKind', data.field, 'kindList');
      return false;
    });
    form.render();
  });





</script>
</body>

</html>
